package edu.hrbu.systemadmin.util;

import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import javax.servlet.http.HttpServletRequest;
import java.util.Objects;

/**
 * @author 徐登宇
 */
public class ConstUtil {

    public static final String TOKEN_PREFIX="TOKEN:";
    public static final String ROLE_PREFIX="ROLE:";
    public static final String PERMS_PREFIX="PERMS:";
    public static final Long HALF_TTL =30L;


    public static final String HEADER_AUTHORIZATION = "Authorization";
    public static final String HEADER_USERNAME = "userName";

    private ConstUtil(){}

    public static HttpServletRequest getRequest(){
        return ((ServletRequestAttributes) Objects.requireNonNull(RequestContextHolder.getRequestAttributes())).getRequest();
    }

}
